package com.lff.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.lff.domain.Role;
import com.lff.mapper.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("role")
public class RoleController {
    @Autowired
    private RoleMapper roleMapper;

    //查出全部的角色信息并返回
    @RequestMapping("findRoles.do")
    @ResponseBody
    public String findAllRole() throws Exception{
        List<Role> roleAll = roleMapper.findRoleAll();
        ObjectMapper om = new ObjectMapper();
        String s = om.writeValueAsString(roleAll);
        return s;
    }
}
